var config = require("config");
cc.Class({
    extends: cc.Component,
    
    properties: {
        xSpeed: cc.Integer,//x轴速度
        ySpeed: cc.Integer,//y轴速度
        hpDrop: cc.Integer, //掉血
        sprArray_bb :{
            default:[],
            type:[cc.SpriteFrame],
        },
    },

    // use this for initialization
    onLoad: function () {
       cc.director.getCollisionManager().enabled=true;
       this.hpDrop = config.PetBulletHpDrop;

       this.bulletGroup_bb = this.node.parent.getComponent('bulletGroup_bb');
    },
    initSpriteFrame(sprIndex,name){
        var nSprite = this.node.getComponent(cc.Sprite);
        nSprite.spriteFrame = this.sprArray_bb[sprIndex];
    },
    //碰撞检测
    onCollisionEnter: function(other,self){
        this.bulletGroup_bb.bulletDied(self.node);
    },
    // called every frame, uncomment this function to activate update callback
    update: function (dt) {
        if (this.bulletGroup_bb.eState != D.commonInfo.gameState.start){
            return ;
        }
        this.node.x += dt*this.xSpeed;
        this.node.y += dt*this.ySpeed;
        
        if ( this.node.y> this.node.parent.height){
            this.bulletGroup_bb.bulletDied(this.node);
        }
    },
    
});
